/**
 * Coryright 2015-2020 www.eyaomall.cn
 * All rights reserved.
 * @author tumingjun
 * @date 2016年8月10日
 *
 */

package com.eyaomall.wxmanage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.eyaomall.wxmanage.dao.ShopDao;
import com.eyaomall.wxmanage.model.vo.ShopVO;
import com.eyaomall.wxmanage.service.ShopService;

/**
 * @author tumingjun
 *
 */
@Service
public class ShopServiceImpl implements ShopService{
	
	@Autowired
	private ShopDao shopDao;

	/**
	 * 激活子账号
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public boolean activeMerchants(ShopVO shopVO) {
		
		shopVO.setStatus("1");
		boolean flag = shopDao.update(shopVO);
		if(flag)
			shopDao.changeStatus(shopVO);
		return flag;
	}

	/**
	 * 冻结子账号
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public boolean unActiveMerchants(ShopVO shopVO) {
		shopVO.setStatus("2");
		boolean flag = shopDao.update(shopVO);
		if(flag)
			shopDao.changeStatus(shopVO);
		return flag;
	}
	
	/**
	 * 延长使用期限服务
	 * @param days 延长的使用天数
	 * @return
	 */
	public boolean delayUseTime(Integer shopid,Integer days) {
		ShopVO shop=new ShopVO();
		shop.setId(shopid);
		shop.setDelaytime(days);
		return shopDao.update("delayUseTime", shop)>0?true:false;
	}

}
